package com.yay.danceline.provider;

import com.yay.danceline.io.DataHandler;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;


/**
 * Get Started!
 * @author yakovlev.yuriy@gmail.com
 * @author Dmitry Makeev
 * 
 * Helper for managing {@link SQLiteDatabase} that stores data for
 * {@link DLProvider}.
 */
public class DLDatabase extends SQLiteOpenHelper {
    private static final String DATABASE_NAME = "danceline.db";

    // NOTE: carefully update onUpgrade() when bumping database versions to make
    // sure user data is saved.
    // released version: 1
    private static final int DATABASE_VERSION = 2;
    private DataHandler mDataHandler;
    private Context context;
    

    public interface Tables {
    	String TRACKS = "tracks";
    }

    public DLDatabase(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        this.context = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        /*db.execSQL("CREATE TABLE " + Tables.TRACKS + " ("
                + BaseColumns._ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
                + TracksColumns.IDP + " INTEGER,"
                + TracksColumns.ARTIST + " TEXT,"
                + TracksColumns.NAME + " TEXT,"
                + TracksColumns.URL + " TEXT)");
        */
        // Insert initial data
        mDataHandler = new DataHandler(context, db);
        //mDataHandler.insertTracks();
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        /*Log.d(TAG, "onUpgrade() from " + oldVersion + " to " + newVersion);
        if(oldVersion != DATABASE_VERSION) {
            Log.w(TAG, "Destroying old data during upgrade");
            db.execSQL("DROP TABLE IF EXISTS " + Tables.TRACKS);

            onCreate(db);
        }*/
    }
}
